/* 
 * File:   SerialPorts.h
 * Author: multitone
 *
 * Created on 15 de Abril de 2011, 14:36
 */

#ifndef SERIALPORTS_H
#define	SERIALPORTS_H
#include <vector>
#include <cstring>
#include <string>
#include <iostream>
#include <unistd.h>	
#include <fcntl.h>	
#include <termios.h>	
#include <sys/types.h>
#include "ShowMsg.h"
#include "DirFile.h"
//
using namespace std;
using std::string;

class SerialPorts:private ShowMsg {
public:
    SerialPorts();
    //
    virtual ~SerialPorts();

    //Seta a porta serial para uso
    bool OpenPort();
    
    bool IsOpen();
    
    void Close();
    
    char ReadChar();
    
    char * ReadAllChar(); 
    
    bool WriteChar(char c[]);
    //
    bool WriteBuffer(char char_buffer[]);

    //
    string getBaud_rate() const {
        return baud_rate;
    }

    void setBaud_rate(string baud_rate) {
        this->baud_rate = baud_rate;
    }

    string getSerial_port() const {
        return serial_port;
    }

    void setSerial_port(string serial_port) {
        this->serial_port = serial_port;
    }

    termios getOptions_atual() const {
        return options_atual;
    }

    void setOptions_atual(termios options_atual) {
        this->options_atual = options_atual;
    }

    termios getOptions_orig() const {
        return options_orig;
    }

    void setOptions_orig(termios options_orig) {
        this->options_orig = options_orig;
    }

private:
    int m_port;
    string serial_port;
    string baud_rate;
    //
    struct termios options_atual;
    struct termios options_orig;
    //
    DirFile *dirfl;
};

#endif	/* SERIALPORTS_H */

